"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".

Replace this with more appropriate tests for your application.
"""

from django.test import TestCase
from tasklists.models import *

class SimpleTest(TestCase):
    

    def setUp(self):
        self.user = AppUser(username="tester", email="test@test.com", first_name="Test", last_name="me")
        self.user.save()
        self.tasklist = TaskList(title="some test list", owner=self.user, description="some description")
        self.tasklist.save()
        self.task = Task(title="Some task name", body="some task to do", list=self.tasklist, owner=self.user, difficulty='E', due_date="2012-12-31T00:00:00Z")
        self.task.save()
        self.task.figure_experience_points()
    
    def test_user_creation(self):
        """
        Test user creation functionality
        """
        self.assertIsInstance(self.user, AppUser)

    def test_tasklist_creation(self):
        self.assertIsInstance(self.tasklist, TaskList)

    def test_task_creation(self):
        self.assertIsInstance(self.task, Task)

    def test_user_exp_award(self):
        self.user.award_experience(10)
        self.assertEquals(self.user.experience_made, 10)

    def test_user_exp_remove(self):
        self.user.award_experience(10)
        self.user.remove_experience(10)
        self.assertEquals(self.user.experience_made, 0)
        
    def test_user_level_up(self):
        self.user.award_experience(100)
        self.assertEquals(self.user.level, 2)
       
    def test_task_completion(self):
        self.user.experience_made = 0
        self.task.complete()
        self.assertEquals(self.user.experience_made, 25)
        
